﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using S4Store.Domain;
using System.ComponentModel.DataAnnotations.Schema;
using S4Store.Domain.FinancialKpi;
using S4Store.Domain.ExhibitionKpi;
using S4Store.Domain.NetMarketingKpi;
using S4Store.Domain.TelSaleKpi;

namespace S4Store.Persistent
{
    public class S4StoreMapping : IEntityMapping
    {
        public void RegisterTo(DbModelBuilder modelBuilder)
        {
            RegisterStore(modelBuilder);
            RegisterAdministrator(modelBuilder);
            RegisterSeller(modelBuilder);
            RegisterPinPai(modelBuilder);
            RegisterCarBrand(modelBuilder);
            RegisterCarModel(modelBuilder);
            //RegisterSellerCarBrandRow(modelBuilder);
            //RegisterSellerCarBrandTable(modelBuilder);

            //RegisterMonthCarSale(modelBuilder);
            //RegisterMonthCarModelSale(modelBuilder);

            RegisterCommonSellerKpi_MonthConfig(modelBuilder);
            RegisterCommonSellerKpi_SellerMonthConfig(modelBuilder);
            RegisterCommonSellerKpi_DayData(modelBuilder);

           // RegisterSellerKpi_MonthConfig(modelBuilder);
            //RegisterSellerKpi_SellerMonthConfig(modelBuilder);
            //RegisterSellerKpi_DayData(modelBuilder);



            RegisterCarKpi_MonthConfig(modelBuilder);
            RegisterCarKpi_CarModelMonthConfig(modelBuilder);
            RegisterCarKpi_DayData(modelBuilder);

            RegisterSellerPerformanceStandard(modelBuilder);
            RegisterImproveGuide(modelBuilder);

            RegisterAfterSaleCarKPI_MonthConfig(modelBuilder);
            RegisterAfterSaleCarKPI_DayInput(modelBuilder);
            RegisterAfterSaleDecorating_MonthConfig(modelBuilder);
            RegisterAfterSaleCarDecorating_DayInput(modelBuilder);
            RegisterAfterSaleServiceAdvisor_MonthTarget(modelBuilder);
            RegisterAfterSaleServiceAdvisor_MonthConfig(modelBuilder);
            RegisterAfterSaleServiceAdvisor_DayInput(modelBuilder);
            RegisterAfterSaleCustomerService_DayInput(modelBuilder);
            RegisterAfterSaleWorkshopManager_MonthConfig(modelBuilder);
            RegisterAfterSaleWorkshopManager_DayInput(modelBuilder);
            RegisteAfterSaleWorkshopManagerMB(modelBuilder);


            RegisterSparePart_MonthInput(modelBuilder);
            RegisterDeadStock(modelBuilder);

            RegisterFinancialMonthConfig(modelBuilder);
            RegisterFinancialCarBrandMonthConfig(modelBuilder);
            RegisterFinancialDayData(modelBuilder);

            RegisteNetMarketingKpiMonthConfig(modelBuilder);
            RegisteNetMarketingKpiMediaMonthConfig(modelBuilder);
            RegisteNetMarketingKpiDayData(modelBuilder);
            RegisteNetMarketingStandard(modelBuilder);
            RegisteNetMarketingMedia(modelBuilder);

            RegisteCarBrandTelSaleMonthConfig(modelBuilder);
            RegisteCarBrandTelSaleDayData(modelBuilder);

            RegisterExhibitionMonthConfig(modelBuilder);
            RegisterExhibitionWeekData(modelBuilder);
            RegisteExhibitionKpiStandard(modelBuilder);

            RegisterAfterSaleMonthStandardConfig(modelBuilder);
            RegisteTelSaleKpiStandard(modelBuilder);

            RegisteInformation(modelBuilder);
            RegisteActionplan(modelBuilder);
        }

        private void RegisterStore(DbModelBuilder modelBuilder)
        {
            //Store
            var config = modelBuilder.Entity<Store>();
            config.ToTable("Store", "system");
            config.HasKey(t => t.Id);

            config.Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();

            config.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(50)
                .IsRequired();

            config.Property(t => t.Address)
                .HasColumnName("Address")
                .HasMaxLength(100)
                .IsOptional();

            config.Property(t => t.Tel)
                .HasColumnName("Tel")
                .HasMaxLength(50)
                .IsOptional();

            config.Property(t => t.Contact)
                .HasColumnName("Contact")
                .HasMaxLength(20)
                .IsRequired();

            config.Property(t => t.Comment)
                .HasColumnName("Comment")
                .IsOptional();

            config.Property(t => t.Code)
                .HasColumnName("Code")
                .IsOptional();

            config.HasOptional(t => t.PinPai)
                .WithMany()
                .HasForeignKey(t => t.PinPaiId);

        }

        private void RegisterAdministrator(DbModelBuilder modelBuilder)
        {
            //Administrator
            var config = modelBuilder.Entity<Administrator>();
            config.ToTable("Administrator", "system");
            config.HasKey(t => t.Id);

            config.Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();

            config.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(50)
                .IsRequired();
            

            config.Property(t => t.UserName)
                .HasColumnName("UserName")
                .HasMaxLength(50)
                .IsRequired();

            config.Property(t => t.Password)
                .HasColumnName("Password")
                .HasMaxLength(50)
                .IsRequired();

            config.Property(t => t.StoreId)
                .HasColumnName("StoreId")
                .IsOptional();

            config.Property(t => t.SessionKey)
                .HasColumnName("SessionKey")
                .HasMaxLength(50)
                .IsOptional();

            config.Property(t => t.PositionType)
                .HasColumnName("PositionType")
                .IsRequired();

            config.Property(t => t.LastLoginDate)
                .HasColumnName("LastLoginDate")
                .IsOptional();

            config.Property(t => t.ThisLoginDate)
                .HasColumnName("ThisLoginDate")
                .IsOptional();

            config.Property(t => t.LoginTimes)
                .HasColumnName("LoginTimes")
                .IsOptional();

            config.Property(t => t.IsClose)
                .HasColumnName("IsClose")
                .IsRequired();

            config.HasOptional(t => t.Store)
                .WithMany(t => t.Administrators)
                .HasForeignKey(t => t.StoreId);


            config.Ignore(t => t.Position);
        }

        private void RegisterSeller(DbModelBuilder modelBuilder)
        {
            //Administrator
            var config = modelBuilder.Entity<Employee>();
            config.ToTable("Employee", "system");
            config.HasKey(t => t.Id);

            config.Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();

            config.Property(t => t.StoreId)
                .HasColumnName("StoreId")
                .IsRequired();

            config.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(50)
                .IsRequired();

            config.Property(t => t.SexType)
                .HasColumnName("Sex")
                .IsOptional();

            config.Property(t => t.Tel)
                .HasColumnName("Tel")
                .HasMaxLength(50)
                .IsOptional();

            config.Property(t => t.WorkStartDate)
                .HasColumnName("WorkStartDate")
                .IsRequired();

            config.Property(t => t.IsClose)
                .HasColumnName("IsClose")
                .IsRequired();
            config.Property(t => t.TypeValue)
                .HasColumnName("TypeValue")
                .IsRequired();


            config.Ignore(t => t.Sex);
            config.Ignore(t => t.WorkYear);
        }

        private void RegisterPinPai(DbModelBuilder modelBuilder)
        {
            //CarBrand
            var config = modelBuilder.Entity<PinPai>();
            config.ToTable("PinPai", "system");
            config.HasKey(t => t.Id);

            config.Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();


            config.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(50)
                .IsRequired();

            config.Property(t => t.IsClose)
                .HasColumnName("IsClose")
                .IsRequired();
        }

        private void RegisterCarBrand(DbModelBuilder modelBuilder)
        {
            //CarBrand
            var config = modelBuilder.Entity<CarBrand>();
            config.ToTable("CarBrand", "system");
            config.HasKey(t => t.Id);

            config.Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();


            config.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(50)
                .IsRequired();

            config.Property(t => t.IsClose)
                .HasColumnName("IsClose")
                .IsRequired();


            config.HasOptional(t => t.PinPai)
                .WithMany(t => t.CarBrands)
                .HasForeignKey(t => t.PinPaiId);
        }

        private void RegisterCarModel(DbModelBuilder modelBuilder)
        {
            //CarBrand
            var config = modelBuilder.Entity<CarModel>();
            config.ToTable("CarModel", "system");
            config.HasKey(t => t.Id);

            config.Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();

            config.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(50)
                .IsRequired();

            config.Property(t => t.BrandId)
                .HasColumnName("BrandId")
                .IsRequired();

            config.Property(t => t.IsClose)
                .HasColumnName("IsClose")
                .IsRequired();


            config.HasRequired(t => t.Brand)
                .WithMany(t => t.CarModels)
                .HasForeignKey(t => t.BrandId);
        }

       
        private void RegisterCommonSellerKpi_MonthConfig(DbModelBuilder modelBuilder)
        {
            //SellerKpi_MonthConfig
            var config = modelBuilder.Entity<S4Store.Domain.CommonSellerKpi.CommonSellerKpiMonthConfig>();
            config.ToTable("SaleKpiMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.Property(t => t.IsConfirmed)
                .HasColumnName("IsConfirmed")
                .IsRequired();

            config.Property(t => t.StoreId)
                .HasColumnName("StoreId")
                .IsRequired();

            config.Property(t => t.LastMonthAvgvr)
                .HasColumnName("LastMonthAvgvr")
                .IsRequired();

            config.Property(t => t.Month)
                .HasColumnName("Month")
                .IsRequired();


            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
        }
        private void RegisterSellerKpi_MonthConfig(DbModelBuilder modelBuilder)
        {
            //SellerKpi_MonthConfig
            var config = modelBuilder.Entity<S4Store.Domain.SellerKpi.SellerKpiMonthConfig>();
            config.ToTable("SellerKpiMonthConfig", "report");

        }
        
        private void RegisterCommonSellerKpi_SellerMonthConfig(DbModelBuilder modelBuilder)
        {
            //SellerKpi_SellerMonthConfig
            var config = modelBuilder.Entity<S4Store.Domain.CommonSellerKpi.CommonSellerMonthConfig>();
            config.ToTable("SaleKpiSellerMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.Property(t => t.IsConfirmed)
                .HasColumnName("IsConfirmed")
                .IsRequired();

            config.Property(t => t.SellerId)
                .HasColumnName("SellerId")
                .IsRequired();
            config.Property(t => t.CarBrandId)
                .HasColumnName("CarBrandId")
                .IsRequired();

            config.Property(t => t.SaleTarget)
                .HasColumnName("SaleTarget")
                .IsRequired();

            config.Property(t => t.LastMonthPotentialClient)
                .HasColumnName("LastMonthPotentialClient")
                .IsRequired();

            config.Property(t => t.Month)
                .HasColumnName("Month")
                .IsRequired();


            config.HasRequired(t => t.Seller)
                .WithMany()
                .HasForeignKey(t => t.SellerId);

            config.HasRequired(t => t.CarBrand)
                .WithMany()
                .HasForeignKey(t => t.CarBrandId);
        }
        private void RegisterSellerKpi_SellerMonthConfig(DbModelBuilder modelBuilder)
        {
            //SellerKpi_SellerMonthConfig
            var config = modelBuilder.Entity<S4Store.Domain.SellerKpi.SellerMonthConfig>();
            config.ToTable("SellerKpiSellerMonthConfig", "report");
        }

        private void RegisterCommonSellerKpi_DayData(DbModelBuilder modelBuilder)
        {
            //SellerKpi_DayData
            var config = modelBuilder.Entity<S4Store.Domain.CommonSellerKpi.CommonSellerKpiDayData>();
            config.ToTable("SaleKpiDayData", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.Property(t => t.IsConfirmed)
                .HasColumnName("IsConfirmed")
                .IsRequired();

            config.Property(t => t.CarBrandId)
                .HasColumnName("CarBrandId")
                .IsRequired();


            config.Property(t => t.SellerId)
                .HasColumnName("SellerId")
                .IsRequired();

            config.Property(t => t.Date)
                .HasColumnName("Date")
                .IsRequired();

            config.Property(t => t.LDJDPC)
                .HasColumnName("LDJDPC")
                .IsRequired();

            config.Property(t => t.SCLDKHDJS)
                .HasColumnName("SCLDKHDJS")
                .IsRequired();


            config.Property(t => t.YXAKJKS)
                .HasColumnName("YXAKJKS")
                .IsRequired();


            config.Property(t => t.SJYQSTXS)
                .HasColumnName("SJYQSTXS")
                .IsRequired();


            config.Property(t => t.SJKHCJS)
                .HasColumnName("SJKHCJS")
                .IsRequired();


            config.Property(t => t.STMXBTXS)
                .HasColumnName("STMXBTXS")
                .IsRequired();


            config.Property(t => t.CXJGCJS)
                .HasColumnName("CXJGCJS")
                .IsRequired();


            config.Property(t => t.ESCPGS)
                .HasColumnName("ESCPGS")
                .IsRequired();


            config.Property(t => t.ZHCJS)
                .HasColumnName("ZHCJS")
                .IsRequired();


            config.Property(t => t.AJCJS)
                .HasColumnName("AJCJS")
                .IsRequired();


            config.Property(t => t.SYYLKHXZDD)
                .HasColumnName("SYYLKHXZDD")
                .IsRequired();


            config.Property(t => t.DYKHXZDD)
                .HasColumnName("DYKHXZDD")
                .IsRequired();


            config.Property(t => t.JCS)
                .HasColumnName("JCS")
                .IsRequired();


            config.Property(t => t.XCBXTBS)
                .HasColumnName("XCBXTBS")
                .IsRequired();


            config.Property(t => t.BXXSE)
                .HasColumnName("BXXSE")
                .IsRequired();


            config.Property(t => t.TCCXSSL)
                .HasColumnName("TCCXSSL")
                .IsRequired();


            config.Property(t => t.YXZHCXSSL)
                .HasColumnName("YXZHCXSSL")
                .IsRequired();


            config.Property(t => t.ZHCZHXSE)
                .HasColumnName("ZHCZHXSE")
                .IsRequired();


            config.Property(t => t.XCYBS)
                .HasColumnName("XCYBS")
                .IsRequired();


            config.Property(t => t.ECCGYYKHS)
                .HasColumnName("ECCGYYKHS")
                .IsRequired();


            config.Property(t => t.DYLKHTJCJS)
                .HasColumnName("DYLKHTJCJS")
                .IsRequired();




            config.HasRequired(t => t.Seller)
                .WithMany()
                .HasForeignKey(t => t.SellerId);

            config.HasRequired(t => t.CarBrand)
                .WithMany()
                .HasForeignKey(t => t.CarBrandId);
        }
        private void RegisterSellerKpi_DayData(DbModelBuilder modelBuilder)
        {
            //SellerKpi_DayData
            var config = modelBuilder.Entity<S4Store.Domain.SellerKpi.SellerKpiDayData>();
            config.ToTable("SellerKpiDayData", "report");
        }

        private void RegisterCarKpi_MonthConfig(DbModelBuilder modelBuilder)
        {
            //CarKpi_MonthConfig
            var config = modelBuilder.Entity<S4Store.Domain.CarKpi.CarKpiMonthConfig>();
            config.ToTable("CarKpiMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.Property(t => t.IsConfirmed)
                .HasColumnName("IsConfirmed")
                .IsRequired();

            config.Property(t => t.StoreId)
                .HasColumnName("StoreId")
                .IsRequired();

            config.Property(t => t.LastMonthAvgvr)
                .HasColumnName("LastMonthAvgvr")
                .IsRequired();

            config.Property(t => t.Month)
                .HasColumnName("Month")
                .IsRequired();
            config.Property(t => t.LastMonthAvgvr)
                .HasColumnName("LastMonthAvgvr")
                .IsRequired();
            config.Property(t => t.OrderQuantityTarget)
                .HasColumnName("OrderQuantityTarget")
                .IsRequired();
            config.Property(t => t.LastMonthReserveDealConversionRate)
                .HasColumnName("LastMonthReserveDealConversionRate")
                .IsRequired();
            config.Property(t => t.InsureTarget)
                .HasColumnName("InsureTarget")
                .IsRequired();
            config.Property(t => t.ReplacementTarget)
                .HasColumnName("ReplacementTarget")
                .IsRequired();
            config.Property(t => t.FinancialTarget)
                .HasColumnName("FinancialTarget")
                .IsRequired();
            config.Property(t => t.ExtendTarget)
                .HasColumnName("ExtendTarget")
                .IsRequired();


            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
        }

        private void RegisterCarKpi_CarModelMonthConfig(DbModelBuilder modelBuilder)
        {
            //CarKpi_CarModelMonthConfig
            var config = modelBuilder.Entity<S4Store.Domain.CarKpi.CarModelMonthConfig>();
            config.ToTable("CarKpiCarModelMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.Property(t => t.IsConfirmed)
                .HasColumnName("IsConfirmed")
                .IsRequired();
            config.Property(t => t.CarModelId).HasColumnName("CarModelId").IsRequired();
            config.Property(t => t.StoreId).HasColumnName("StoreId").IsRequired();
            config.Property(t => t.SaleTarget).HasColumnName("SaleTarget").IsRequired();
            config.Property(t => t.Month).HasColumnName("Month").IsRequired();
            config.Property(t => t.LastMonthInventory).HasColumnName("LastMonthInventory").IsRequired();
            config.Property(t => t.LastMonthGive).HasColumnName("LastMonthGive").IsRequired();
            config.Property(t => t.LastMonthNotGive).HasColumnName("LastMonthNotGive").IsRequired();
            config.Property(t => t.IsStandardEquipped).HasColumnName("IsStandardEquipped").IsRequired();
            config.Property(t => t.IsLstTenVersion).HasColumnName("IsLstTenVersion").IsRequired();
            config.Property(t => t.IsMidTenVersion).HasColumnName("IsMidTenVersion").IsRequired();
            config.Property(t => t.IsLastTenVersion).HasColumnName("IsLastTenVersion").IsRequired();

            config.HasRequired(t => t.CarModel).WithMany().HasForeignKey(t => t.CarModelId);
            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);

            config.Ignore(t => t.Enble);
        }


        private void RegisterCarKpi_DayData(DbModelBuilder modelBuilder)
        {
            //CarKpi_DayData
            var config = modelBuilder.Entity<S4Store.Domain.CarKpi.CarKpiDayData>();
            config.ToTable("CarKpiDayData", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.Property(t => t.IsConfirmed)
                .HasColumnName("IsConfirmed")
                .IsRequired();



            config.Property(t => t.CarModelId)
                .HasColumnName("CarModelId")
                .IsRequired();

            config.Property(t => t.StoreId)
                .HasColumnName("StoreId")
                .IsRequired();
            config.Property(t => t.Date)
                .HasColumnName("Date")
                .IsRequired();

            config.Property(t => t.BDYD)
                .HasColumnName("BDYD")
                .IsRequired();

            config.Property(t => t.EWYD)
                .HasColumnName("EWYD")
                .IsRequired();

            config.Property(t => t.AKC).HasColumnName("AKC").IsRequired();
            config.Property(t => t.BKC).HasColumnName("BKC").IsRequired();
            config.Property(t => t.CKC).HasColumnName("CKC").IsRequired();
            config.Property(t => t.CKL).HasColumnName("CKL").IsRequired();
            config.Property(t => t.YT).HasColumnName("YT").IsRequired();
            config.Property(t => t.EWYJ).HasColumnName("EWYJ").IsRequired();
            config.Property(t => t.BDYJ).HasColumnName("BDYJ").IsRequired();
            config.Property(t => t.HYWKH).HasColumnName("HYWKH").IsRequired();
            config.Property(t => t.AYWKH).HasColumnName("AYWKH").IsRequired();
            config.Property(t => t.BYWKH).HasColumnName("BYWKH").IsRequired();
            config.Property(t => t.HDJKH).HasColumnName("HDJKH").IsRequired();
            config.Property(t => t.ADJKH).HasColumnName("ADJKH").IsRequired();
            config.Property(t => t.BDJKH).HasColumnName("BDJKH").IsRequired();
            config.Property(t => t.TB).HasColumnName("TB").IsRequired();
            config.Property(t => t.ZH).HasColumnName("ZH").IsRequired();
            config.Property(t => t.AJ).HasColumnName("AJ").IsRequired();
            config.Property(t => t.YB).HasColumnName("YB").IsRequired();
            config.Property(t => t.LstTenVersion).HasColumnName("LstTenVersion").IsRequired();
            config.Property(t => t.MidTenVersion).HasColumnName("MidTenVersion").IsRequired();
            config.Property(t => t.LastTenVersion).HasColumnName("LastTenVersion").IsRequired();
            config.Property(t => t.NotPackageDecorateCount).HasColumnName("NotPackageDecorateCount").IsRequired();
            config.Property(t => t.NotPackageDecorateValue).HasColumnName("NotPackageDecorateValue").IsRequired();


            config.HasRequired(t => t.CarModel)
                .WithMany()
                .HasForeignKey(t => t.CarModelId);
            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
        }


        private void RegisterSellerPerformanceStandard(DbModelBuilder modelBuilder)
        {
            //SellerPerformanceStandard
            var config = modelBuilder.Entity<S4Store.Domain.Report.SellerPerformanceStandard>();
            config.ToTable("SellerPerformanceStandard", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
        }

        private void RegisterImproveGuide(DbModelBuilder modelBuilder)
        {
            //SellerPerformanceStandard
            var config = modelBuilder.Entity<S4Store.Domain.ImproveGuide>();
            config.ToTable("ImproveGuide", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();
            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
        }
        
        private void RegisterAfterSaleCarKPI_MonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleCarTypeMonthConfig>();
            config.ToTable("AfterSaleCarTypeMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.CarBrand).WithMany().HasForeignKey(t => t.CarBrandId);
            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
            

        }

        private void RegisterAfterSaleCarKPI_DayInput(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleCarTypeDayInput>();
            config.ToTable("AfterSaleCarTypeDayInput", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();


            config.HasRequired(t => t.CarBrand).WithMany().HasForeignKey(t => t.CarBrandId);
            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisterAfterSaleDecorating_MonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleCarDecoratingMonthConfig>();
            config.ToTable("AfterSaleCarDecoratingMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();


            config.HasRequired(t => t.CarBrand).WithMany().HasForeignKey(t => t.CarBrandId);
            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisterAfterSaleCarDecorating_DayInput(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleCarDecoratingDayInput>();
            config.ToTable("AfterSaleCarDecoratingDayInput", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();


            config.HasRequired(t => t.CarBrand).WithMany().HasForeignKey(t => t.CarBrandId);
            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisterAfterSaleServiceAdvisor_MonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleServiceAdvisorMonthConfig>();
            config.ToTable("AfterSaleServiceAdvisorMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisterAfterSaleServiceAdvisor_MonthTarget(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleServiceAdvisorMonthTarget>();
            config.ToTable("AfterSaleServiceAdvisorMonthTarget", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Employee).WithMany().HasForeignKey(t => t.EmployeeId);
        }

        private void RegisterAfterSaleServiceAdvisor_DayInput(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleServiceAdvisorDayInput>();
            config.ToTable("AfterSaleServiceAdvisorDayInput", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Employee).WithMany().HasForeignKey(t => t.EmployeeId);
        }

        private void RegisterAfterSaleCustomerService_DayInput(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleCustomerServiceDayInput>();
            config.ToTable("AfterSaleCustomerServiceDayInput", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Employee).WithMany().HasForeignKey(t => t.EmployeeId);
        }

        private void RegisterSparePart_MonthInput(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.SparePartsMonthInput>();
            config.ToTable("SparePartsMonthInput", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisterDeadStock(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.DeadStock>();
            config.ToTable("DeadStock", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisterAfterSaleWorkshopManager_MonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleWorkshopManagerMonthConfig>();
            config.ToTable("AfterSaleWorkshopManagerMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Employee).WithMany().HasForeignKey(t => t.EmployeeId);
        }

        private void RegisterAfterSaleWorkshopManager_DayInput(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<S4Store.Domain.AfterSaleKpi.AfterSaleWorkshopManagerDayInput>();
            config.ToTable("AfterSaleWorkshopManagerDayInput", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Employee).WithMany().HasForeignKey(t => t.EmployeeId);
        }



        private void RegisterFinancialMonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<FinancialMonthConfig>();
            config.ToTable("FinancialMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }
        private void RegisterFinancialCarBrandMonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<FinancialCarBrandMonthConfig>();
            config.ToTable("FinancialCarBrandMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
            config.HasRequired(t => t.CarBrand).WithMany().HasForeignKey(t => t.CarBrandId);
        }
        private void RegisterFinancialDayData(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<FinancialDayData>();
            config.ToTable("FinancialDayData", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
            config.HasRequired(t => t.CarBrand).WithMany().HasForeignKey(t => t.CarBrandId);
        }

        private void RegisterExhibitionMonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<ExhibitionMonthConfig>();
            config.ToTable("ExhibitionMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }
        private void RegisterExhibitionWeekData(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<ExhibitionWeekData>();
            config.ToTable("ExhibitionWeekData", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisteNetMarketingMedia(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<NetMarketingMedia>();
            config.ToTable("NetMarketingMedia", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId).WillCascadeOnDelete(false);
        }

        private void RegisteNetMarketingKpiMonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<NetMarketingKpiMonthConfig>();
            config.ToTable("NetMarketingKpiMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisteNetMarketingKpiMediaMonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<NetMarketingKpiMediaMonthConfig>();
            config.ToTable("NetMarketingKpiMediaMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
            config.HasRequired(t => t.Media).WithMany().HasForeignKey(t => t.MediaId);
        }

        private void RegisteNetMarketingKpiDayData(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<NetMarketingKpiDayData>();
            config.ToTable("NetMarketingKpiDayData", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
            config.HasRequired(t => t.Media).WithMany().HasForeignKey(t => t.MediaId);
        }

        private void RegisteNetMarketingStandard(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<NetMarketingStandard>();
            config.ToTable("NetMarketingStandard", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisteCarBrandTelSaleMonthConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<CarBrandTelSaleMonthConfig>();
            config.ToTable("CarBrandTelSaleMonthConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
            config.HasRequired(t => t.CarBrand).WithMany().HasForeignKey(t => t.CarBrandId);
        }

        private void RegisteCarBrandTelSaleDayData(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<CarBrandTelSaleDayData>();
            config.ToTable("CarBrandTelSaleDayData", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
            config.HasRequired(t => t.CarBrand).WithMany().HasForeignKey(t => t.CarBrandId);
        }

        private void RegisteAfterSaleWorkshopManagerMB(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<Domain.AfterSaleKpi.AfterSaleWorkshopManagerMB>();
            config.ToTable("AfterSaleWorkshopManagerMB", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();

            config.HasRequired(t => t.Store).WithMany().HasForeignKey(t => t.StoreId);
        }

        private void RegisteExhibitionKpiStandard(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<ExhibitionKpiStandard>();
            config.ToTable("ExhibitionKpiStandard", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();
            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
            config.Property(t => t.ZTHDDCJKCB)
                  .HasPrecision(18, 2);
        }
        private void RegisterAfterSaleMonthStandardConfig(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<Domain.AfterSaleKpi.MonthStandardConfig>();
            config.ToTable("AfterSaleMonthStandardConfig", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();
            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
        }
        private void RegisteTelSaleKpiStandard(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<TelSaleKpiStandard>();
            config.ToTable("TelSaleKpiStandard", "report");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();
            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
        }


        private void RegisteInformation(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<Information>();
            config.ToTable("Information", "system");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();
        }

        private void RegisteActionplan(DbModelBuilder modelBuilder)
        {
            var config = modelBuilder.Entity<Actionplan>();
            config.ToTable("Actionplan", "system");

            config.Property(t => t.Id)
               .HasColumnName("Id")
               .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
               .IsRequired();
            config.HasRequired(t => t.Store)
                .WithMany()
                .HasForeignKey(t => t.StoreId);
            config.HasRequired(t => t.AppUser)
                .WithMany()
                .HasForeignKey(t => t.AppUserId);
        }
    }
}
